﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>List of Control Functions | AutoHotkey v2</title>
<meta name="description" content="This page lists functions to retrieve information about a control, or make a variety of changes to a control." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>Control Functions</h1>

<p>Functions to retrieve information about a control, or make a variety of changes to a control. Click on a function name for details.</p>
<table class="info">
  <tr>
    <th>函数</th>
    <th>描述</th>
  </tr>
  <tr>
    <td><a href="ControlAddItem.htm">ControlAddItem</a></td>
    <td>添加指定的字符串作为 ListBox(列表框) 或 ComboBox(组合框) 底部的新条目.</td>
  </tr>
  <tr>
    <td><a href="ControlChoose.htm">ControlChoose</a></td>
    <td>设置列表框或组合框中的选择为指定的条目编号.</td>
  </tr>
  <tr>
    <td><a href="ControlChooseString.htm">ControlChooseString</a></td>
    <td>将 ListBox 或 ComboBox 中的选择设置为其开头部分与指定字符串匹配的第一个条目.</td>
  </tr>
  <tr>
    <td><a href="ControlClick.htm">ControlClick</a></td>
    <td>发送鼠标按钮或鼠标滚轮事件到控件.</td>
  </tr>
  <tr>
    <td><a href="ControlDeleteItem.htm">ControlDeleteItem</a></td>
    <td>从 ListBox 或 ComboBox 中删除指定的条目.</td>
  </tr>
  <tr>
    <td><a href="ControlEditPaste.htm">ControlEditPaste</a></td>
    <td>将指定的字符串粘贴到 Edit 控件中的插入符号(文本插入点) 处.</td>
  </tr>
  <tr>
    <td><a href="ControlFindItem.htm">ControlFindItem</a></td>
    <td>返回与指定字符串完全匹配的 ListBox 或 ComboBox 的条目的编号.</td>
  </tr>
  <tr>
    <td><a href="ControlFocus.htm">ControlFocus</a></td>
    <td>设置输入焦点到窗口的指定控件上.</td>
  </tr>
  <tr>
    <td><a href="ControlGetChecked.htm">ControlGetChecked</a></td>
    <td>如果选中复选框或单选按钮, 则返回非零值.</td>
  </tr>
  <tr>
    <td><a href="ControlGetChoice.htm">ControlGetChoice</a></td>
    <td>返回列表框或组合框中当前选定项的名称.</td>
  </tr>
  <tr>
    <td><a href="ControlGetClassNN.htm">ControlGetClassNN</a></td>
    <td>返回指定控件的 ClassNN(类名和序号).</td>
  </tr>
  <tr>
    <td><a href="ControlGetCurrentCol.htm">ControlGetCurrentCol</a></td>
    <td>返回插入符号(文本插入点) 在的 Edit 控件中的列号.</td>
  </tr>
  <tr>
    <td><a href="ControlGetCurrentLine.htm">ControlGetCurrentLine</a></td>
    <td>返回插入符号(插入点) 在的 Edit 控件中的行号.</td>
  </tr>
  <tr>
    <td><a href="ControlGetEnabled.htm">ControlGetEnabled</a></td>
    <td>如果指定的控件是启用的, 则返回非零值.</td>
  </tr>
  <tr>
    <td><a href="ControlGetFocus.htm">ControlGetFocus</a></td>
    <td>如果有, 则获取目标窗口中具有输入焦点的控件.</td>
  </tr>
  <tr>
    <td><a href="ControlGetHwnd.htm">ControlGetHwnd</a></td>
    <td>返回指定控件的唯一 ID.</td>
  </tr>
  <tr>
    <td><a href="ControlGetLine.htm">ControlGetLine</a></td>
    <td>返回 Edit 控件中指定行的文本.</td>
  </tr>
  <tr>
    <td><a href="ControlGetLineCount.htm">ControlGetLineCount</a></td>
    <td>返回 Edit 控件的行数.</td>
  </tr>
  <tr>
    <td><a href="ControlGetList.htm">ControlGetList</a></td>
    <td>从列表视图, 列表框, 组合框或下拉列表中返回项目/行的列表.</td>
  </tr>
  <tr>
    <td><a href="ControlGetPos.htm">ControlGetPos</a></td>
    <td>获取控件的位置和大小.</td>
  </tr>
  <tr>
    <td><a href="ControlGetSelected.htm">ControlGetSelected</a></td>
    <td>返回 Edit 控件中选定的文本.</td>
  </tr>
  <tr>
    <td><a href="ControlGetStyle.htm">ControlGetStyle<br>ControlGetExStyle</a></td>
    <td>返回表示指定控件样式或扩展样式的整数.</td>
  </tr>
  <tr>
    <td><a href="ControlGetTab.htm">ControlGetTab</a></td>
    <td>返回 SysTabControl32 中所选选项卡的位置编号.</td>
  </tr>
  <tr>
    <td><a href="ControlGetText.htm">ControlGetText</a></td>
    <td>从控件检索文本.</td>
  </tr>
  <tr>
    <td><a href="ControlGetVisible.htm">ControlGetVisible</a></td>
    <td>如果指定的控件可见, 则返回非零值.</td>
  </tr>
  <tr>
    <td><a href="ControlHide.htm">ControlHide</a></td>
    <td>隐藏指定控件.</td>
  </tr>
  <tr>
    <td><a href="ControlHideDropDown.htm">ControlHideDropDown</a></td>
    <td>隐藏 ComboBox 控件的下拉列表.</td>
  </tr>
  <tr>
    <td><a href="ControlMove.htm">ControlMove</a></td>
    <td>移动或调整控件.</td>
  </tr>
  <tr>
    <td><a href="ControlSend.htm">ControlSend<br>ControlSendText</a></td>
    <td>向窗口或控件发送模拟的击键或文本.</td>
  </tr>
  <tr>
    <td><a href="ControlSetChecked.htm">ControlSetChecked</a></td>
    <td>打开(选中) 或关闭(取消选中) 复选框或单选按钮.</td>
  </tr>
  <tr>
    <td><a href="ControlSetEnabled.htm">ControlSetEnabled</a></td>
    <td>启用或禁用指定的控件.</td>
  </tr>
  <tr>
    <td><a href="ControlSetStyle.htm">ControlSetStyle<br>ControlSetExStyle</a></td>
    <td>分别更改指定控件的样式或扩展样式.</td>
  </tr>
  <tr>
    <td><a href="ControlSetTab.htm">ControlSetTab</a></td>
    <td>选择 SysTabControl32 中选项卡的指定位置.</td>
  </tr>
  <tr>
    <td><a href="ControlSetText.htm">ControlSetText</a></td>
    <td>更改控件的文本.</td>
  </tr>
  <tr>
    <td><a href="ControlShow.htm">ControlShow</a></td>
    <td>如果指定的控件先前是隐藏的, 则显示该控件.</td>
  </tr>
  <tr>
    <td><a href="ControlShowDropDown.htm">ControlShowDropDown</a></td>
    <td>显示 ComboBox 控件的下拉列表.</td>
  </tr>
</table>

<h2 id="Parameter">The <em>Control</em> Parameter</h2>
<p>Functions which operate on individual controls have a parameter named <em>Control</em> which supports a few different ways to identify the control. The <em>Control</em> parameter can be one of the following:</p>
<p><strong>ClassNN</strong> (<a href="../Concepts.htm#strings">String</a>): The ClassNN (classname and instance number) of the control, which can be determined via Window Spy. For example "Edit1" is the first control with classname "Edit".</p>
<p><strong>Text</strong> (<a href="../Concepts.htm#strings">String</a>): The control's text. The matching behavior is determined by <a href="SetTitleMatchMode.htm">SetTitleMatchMode</a>.</p>
<p><strong>HWND</strong> (<a href="../Concepts.htm#numbers">Integer</a>): The control's HWND, which is typically retrieved via <a href="ControlGetHwnd.htm">ControlGetHwnd</a>, <a href="MouseGetPos.htm">MouseGetPos</a>, or <a href="DllCall.htm">DllCall</a>. This also works on hidden controls even when <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> is Off. Any subsequent window parameters are ignored.</p>
<p><strong>Object</strong>: An object of any type with a <code>Hwnd</code> property, such as a <a href="../objects/GuiControl.htm">GuiControl</a>. An exception is thrown if the object has no <code>Hwnd</code> property or it does not return a pure integer. Any subsequent window parameters are ignored.</p>
<p><strong>Omitted</strong>: A few functions are able to operate on either a control or a top-level window. Omitting the <em>Control</em> parameter causes the function to use the target window (specified by <em><a href="../misc/WinTitle.htm">WinTitle</a></em>) instead of one of its controls. 例如, <a href="ControlSend.htm">ControlSend</a> can send keyboard messages directly to the window.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>如果遇到问题, <a href="../misc/ErrorLevel.htm">ErrorLevel</a> 设置为 1, 否则设置为 0. Unless specified otherwise, each function also returns 1 (true) to indicate success or 0 (false) to indicate failure.</p>
<p>如果检测到无效参数, 则抛出<a href="Catch.htm#RuntimeErrors">异常</a>.</p>

<h2 id="Remarks">备注</h2>
<p>To improve reliability, a delay is done automatically after each use of a Control function that changes a control (except for <a href="ControlSetStyle.htm">ControlSetStyle</a> and <a href="ControlSetStyle.htm">ControlSetExStyle</a>). 该延迟可以通过 <a href="SetControlDelay.htm">SetControlDelay</a> 或给 <a href="../Variables.htm#ControlDelay">A_ControlDelay</a> 赋值来更改. 有关详情, 请参阅 <a href="SetControlDelay.htm#Remarks">SetControlDelay 备注</a>.</p>
<p>To discover the ClassNN or HWND of the control that the mouse is currently hovering over, use <a href="MouseGetPos.htm">MouseGetPos</a>.</p>
<p>To retrieve a list of all controls in a window, use <a href="WinGetControls.htm">WinGetControls</a> or <a href="WinGetControlsHwnd.htm">WinGetControlsHwnd</a>.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="SetControlDelay.htm">SetControlDelay</a>, <a href="Win.htm">Win functions</a>, <a href="../objects/GuiControl.htm">GuiControl object</a> (for controls created by the script)</p>

</body>
</html>